<template>
  <div class="news">
    <img :src="list.thumb_img" />
    <div class="news-content">
      <h3>{{ list.title }}</h3>
      <p class="filters">
        <span>{{ list.click_rate }}次预览</span>
        <span>{{ list.created_at | formatDate }}</span>
      </p>
      <div class="ct">{{ list.description }}</div>
      <van-divider />
      <div v-html="list.content"></div>
    </div>
  </div>
</template>'
<script>
export default {
  filters: {
    formatDate: function (val) {
      let d1 = Number(val) * 1000;
      let date = new Date(d1);
      //注意对方给你的是毫秒还是秒，如果是毫秒需要转秒（*1000）
      // let y = date.getFullYear();
      let MM = date.getMonth() + 1;
      MM = MM < 10 ? "0" + MM : MM;
      let d = date.getDate();
      d = d < 10 ? "0" + d : d;
      // let h = date.getHours();
      // h = h < 10 ? "0" + h : h;
      // let m = date.getMinutes();
      // m = m < 10 ? "0" + m : m;
      // let s = date.getSeconds();
      // s = s < 10 ? "0" + s : s;
      return MM + "/" + d;
    },
  },
  data() {
    return {
      list: [],
    };
  },
  mounted() {
    this.getnews();
  },
  methods: {
    getnews() {
      this.$API
        .information({ information_id: this.$route.query.id })
        .then((res) => {
          console.log(res);
          this.list = res.data.data;
        });
    },
  },
};
</script>
<style lang="scss">
.news {
  width: 100%;
  img {
    width: 100%;
    height: 15rem;
  }
  .news-content {
    box-sizing: border-box;
    padding: 10px 14px;
  }
  .filters {
    display: flex;
    justify-content: space-between;
    color: #999999;
    font-size: 14px;
  }
  .ct {
    width: 60%;
    margin: 0 auto;
    color: #999999;
    font-size: 17px;
  }
}
</style>